package com.listeningframework.boot.autoconfigure.mail;

import javax.mail.internet.MimeMessage;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import com.listeningframework.boot.autoconfigure.mail.senders.ListeningCustomMailSender;
import com.listeningframework.boot.autoconfigure.mail.senders.ListeningSystemMailSender;

/**
 * Listening Mail Configuration
 * 
 * @author listening
 * @version $Id: MDCFilterRegister.java, v 0.1 2015年8月23日 下午12:07:21 listening Exp $
 */
@Configuration
@ConditionalOnClass({ MimeMessage.class, JavaMailSender.class })
@AutoConfigureAfter(MailSenderAutoConfiguration.class)
@ConditionalOnSingleCandidate(JavaMailSenderImpl.class)
public class ListeningMailConfiguration {
    /**
     * Listening Custom Mail Sender
     *
     * @return ListeningCustomMailSender
     */
    @Bean(name = "listeningCustomMailSender")
    public ListeningCustomMailSender getListeningCustomMailSender() {
        return new ListeningCustomMailSender();
    }

    /**
     * Listening System Mail Sender
     *
     * @return ListeningSystemMailSender
     */
    @Bean(name = "listeningSystemMailSender")
    public ListeningSystemMailSender getListeningSystemMailSender() {
        return new ListeningSystemMailSender();
    }
}
